package cn.edu.tju.elm.repository;

import cn.edu.tju.elm.model.Cart;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;

import java.util.List;

/**
 * ClassName: CartRepository
 * Package: cn.edu.tju.elm.repository
 * Description:
 *
 * @Author Niu Wenhang
 * @Create 2025/9/17 22:02
 * @Version 1.0
 */
public interface CartRepository extends JpaRepository<Cart, Long> {
    public List<Cart> findAllByCustomerIdAndBusinessId(Long userId, Long businessId);
    public List<Cart> findByCustomerIdAndDeletedFalse(Long customerId);
    public void deleteByCustomerId(Long customerId);
    
    // 根据用户ID和店铺ID查询购物车
    public List<Cart> findByCustomerIdAndBusinessIdAndDeletedFalse(Long customerId, Long businessId);
    
    // 根据用户ID和商品ID查询购物车
    public List<Cart> findByCustomerIdAndFoodIdAndDeletedFalse(Long customerId, Long foodId);
}
